import java.util.*;
public class task2 {

	public static void main(String[] args) {
		
		int size , i , fmax=0 , fmin=0;
		double max , min;

		Scanner sc= new Scanner(System.in);

		do{
		System.out.print("Enter the array size: ");
		size = sc.nextInt();

		if(size<1)
		System.out.println("Error: invalid input");
		}while(size<1);

		double[] a = new double[size];

		System.out.print("Enter element at index# 0 of the array: ");
		a[0]=sc.nextDouble();

		max = min = a[0];

		for(i=1 ; i<a.length ; i++)
		{
			System.out.printf("Enter element at index# %d of the array: ",i);
			a[i]=sc.nextDouble();
			if(a[i]<min)
			{
				min = a[i];
				fmin = i;
			}
			
			else if(a[i]>max)
			{
				max = a[i];
				fmax = i;
			}
		}

		System.out.printf("%n%nMax value = %.2f, its first occurrence is at index# %d",max,fmax);
		System.out.printf("%nMin value = %.2f, its first occurrence is at index# %d",min,fmin);

		sc.close();

	}

}
